<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>云盘首页</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="layui/dist/css/layui.css"  media="all">
    <script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript">
        $(function(){
            $("#userId").blur(function(){
                var userId = $("#userId").val();
                if(userId==""){
                    $("#msg").text("用户名不能为空！");
                    $("#userId").focus();
                    return false;
                } else{
                    $("#msg").text("");
                }
                //验证用户是否存在
                $.ajax({
                    url:"checkUserByUserId",
                    type:"get",
                    data:{userId:userId},
                    dataType:"json",
                    success:function(data,textStatus) {
                        if(data){
                            $("#msg").text("用户名已存在！");
                            //$("#userId").val();
                            $("#userId").focus();
                        }else {

                        }
                    },
                    error:function(textStatus) {
                        alert("系统出错，请联系管理员，状态码为",textStatus);
                    }
                })
            });

            $("#registerBtn").click(function(){
                var userId = $("#userId").val();
                var realName = $("#realName").val();
                var password = $("#password").val();
                if(userId=="" || realName=="" || password==""){
                    $("#msg").text("用户名，真实姓名，密码均不能为空！");
                    return false;
                }
            });
        });

    </script>
</head>
<body>

<div style="margin: 0 auto; width:60%">
    <form class="layui-form" action="saveUser" lay-filter="example">
        <h1 style="color: #1E9FFF;text-align: center;margin-top: 100px;margin-bottom: 50px">云盘注册中心</h1>

        <div class="layui-form-item">
            <label class="layui-form-label">用户名：</label>
            <div class="layui-input-block">
                <input type="text" name="userId" id="userId" lay-verify="title" autocomplete="off" placeholder="请输入用户名" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">真实姓名：</label>
            <div class="layui-input-block">
                <input type="text" name="realName" id="realName" lay-verify="title" autocomplete="off" placeholder="请输入真实姓名" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码：</label>
            <div class="layui-input-block">
                <input type="password" name="password" id="password" placeholder="请输入密码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">电话：</label>
            <div class="layui-input-block">
                <input type="text" name="tel" lay-verify="title" autocomplete="off" placeholder="请输入手机号或者固话" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">邮箱：</label>
            <div class="layui-input-block">
                <input type="text" name="email" lay-verify="title" autocomplete="off" placeholder="请输入邮箱" class="layui-input">
            </div>
        </div>
        <p style="height: 50px; text-align: center"> <span id="msg"></span></p>
        <div class="layui-form-item" style="text-align: center">
            <div class="">
                <button type="submit" class="layui-btn" lay-submit="" id="registerBtn" lay-filter="demo1">立即注册</button>
            </div>
        </div>
    </form>
</div>
</body>
</html>